package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @version v1.0
 * @apiNote 菜品套餐中间表映射持久层
 * @author OldGj 2024/5/12
 */
@Mapper
public interface SetmealDishMapper {

    /**
     * 根据菜品ID查看套餐ID
     * @param dishIds
     * @return
     */
    List<Long> getSetmealIdsByDishIds(List<Long> dishIds);

    /**
     * 新增套餐菜品关系
     * @param setmealDishes
     */
    void insertBatch(List<SetmealDish> setmealDishes);


    /**
     * 删除套餐菜品关系表中的数据
     * @param setmealIds
     */
    void deleteBatch(List<Long> setmealIds);


    /**
     * 根据套餐ID查询套餐与菜品的关系信息
     * @param setmealId
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> findById(Long setmealId);

    /**
     * 根据ID删除套餐菜品关系
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deleteById(Long setmealId);
}
